package com.market.cash.ui.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.market.cash.R
import com.market.cash.configs.CashRootConfigs
import com.market.cash.utils.CashRootImageUtil
import com.market.cash.utils.adapter.CashRootRecyclerViewAdapter
import com.market.cash.utils.adapter.CashRootViewHolderHelper
import org.json.JSONObject

/**
 * CashRoot
 * @Author wwdeng
 * @CreateTime: 2024/10/28 11:51
 * @Annotation：贷款详情 - 账户列表
 */
class CashRootOrderDetailsAccountAdapter(recyclerView: RecyclerView?) : CashRootRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.cash_account_item) {
    override fun setItemChildListener(helper: CashRootViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout) //点击Item
        helper.setItemChildClickListener(R.id.imgDelete)//删除
    }
    override fun fillData(helper: CashRootViewHolderHelper, position: Int, model: JSONObject) {
        var showName = model.optString("name","")
        if (showName.isEmpty() || showName == "null"){
            showName = "test"
        }
        helper.setText(R.id.textTitle,showName)
        helper.setText(R.id.textMobile,"+" + model.optString("account"))
        val imgLogo = helper.getImageView(R.id.imgLogo)
        CashRootImageUtil.instance.loadImageUrl(mContext,imgLogo,model.optString("logo"), R.mipmap.cash_holder)

        //法语地区显示删除按钮
        if (CashRootConfigs.isFrench()){
            helper.setVisibility(R.id.imgDelete, View.VISIBLE)
        } else {
            helper.setVisibility(R.id.imgDelete, View.GONE)
        }
    }
}